﻿namespace ClearLines.Bumblebee.Tests

open ClearLines.Bumblebee
open NUnit.Framework
open FsUnit

[<TestFixture>]
type SolverTests() =

   [<Test>]
   member test.``active bees should default to defaultActiveBees``() =

      let solver = new Solver<string>()
      solver.ActiveBees |> should equal Hive.defaultActiveBees

   [<Test>]
   member test.``scout bees should default to defaultScoutBees``() =

      let solver = new Solver<string>()
      solver.ScoutBees |> should equal Hive.defaultScoutBees

   [<Test>]
   member test.``inactive bees should default to defaultInactiveBees``() =

      let solver = new Solver<string>()
      solver.InactiveBees |> should equal Hive.defaultInactiveBees

   [<Test>]
   member test.``proba mistake should default to defaultProbaMistake``() =

      let solver = new Solver<string>()
      solver.ProbaMistake |> should equal Hive.defaultProbaMistake

   [<Test>]
   member test.``proba convince should default to defaultProbaConvince``() =

      let solver = new Solver<string>()
      solver.ProbaConvince |> should equal Hive.defaultProbaConvince

   [<Test>]
   member test.``trips should default to defaultTrips``() =

      let solver = new Solver<string>()
      solver.Trips |> should equal Hive.defaultTrips

   [<Test>]
   member test.``active bees should be settable``() =

      let solver = new Solver<string>()
      solver.ActiveBees <- 42
      solver.ActiveBees |> should equal 42

   [<Test>]
   member test.``scout bees should be settable``() =

      let solver = new Solver<string>()
      solver.ScoutBees <- 42
      solver.ScoutBees |> should equal 42

   [<Test>]
   member test.``inactive bees should be settable``() =

      let solver = new Solver<string>()
      solver.InactiveBees <- 42
      solver.InactiveBees |> should equal 42

   [<Test>]
   member test.``proba mistake should be settable``() =

      let solver = new Solver<string>()
      solver.ProbaMistake <- 0.42
      solver.ProbaMistake |> should equal 0.42

   [<Test>]
   member test.``proba convince should be settable``() =

      let solver = new Solver<string>()
      solver.ProbaConvince <- 0.42
      solver.ProbaConvince |> should equal 0.42

   [<Test>]
   member test.``trips should be settable``() =

      let solver = new Solver<string>()
      solver.Trips <- 42
      solver.Trips |> should equal 42

   [<Test>]
   member test.``Setting negative active bees should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.ActiveBees <- -1) 
      |> should throw typeof<System.ArgumentException>

   [<Test>]
   member test.``Setting negative scout bees should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.ScoutBees <- -1)
      |> should throw typeof<System.ArgumentException>

   [<Test>]
   member test.``Setting zero inactive bees should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.InactiveBees <- 0)
      |> should throw typeof<System.ArgumentException>

   [<Test>]
   member test.``Setting negative proba mistake should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.ProbaMistake <- -0.1)
      |> should throw typeof<System.ArgumentException>

   [<Test>]
   member test.``Setting proba mistake above 1.0 should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.ProbaMistake <- 1.1)
      |> should throw typeof<System.ArgumentException>

   [<Test>]
   member test.``Setting negative proba convince should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.ProbaConvince <- -0.1)
      |> should throw typeof<System.ArgumentException>

   [<Test>]
   member test.``Setting proba convince above 1.0 should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.ProbaConvince <- 1.1)
      |> should throw typeof<System.ArgumentException>

   [<Test>]
   member test.``Setting negative trips should throw``() =

      let solver = new Solver<string>()
      (fun () -> solver.Trips <- -1)
      |> should throw typeof<System.ArgumentException>
